package cn.lijia.itrip.common;

import cn.lijia.itrip.model.ItripUser;
import com.alibaba.fastjson.JSON;

/**
 * @author 李嘉
 * @create 2018-08-30-11:24
 */

public class ValidationUtil {

    private RedisAPI redisAPI;

    /**
     * 获取redis中存储的token
     * @param token
     * @return
     */
    public ItripUser getUser(String token) {
        if (!redisAPI.exists(token)) {
            return null;
        }
        String itripUserJSON = redisAPI.get(token);

        //json ---> bean
        ItripUser itripUser = JSON.parseObject(itripUserJSON, ItripUser.class);
        return itripUser;
    }

    public void setRedisAPI(RedisAPI redisAPI) {
        this.redisAPI = redisAPI;
    }
}
